//
//  ViewController.m
//  AddContact
//
//  Created by MyMac on 15/10/29.
//  Copyright © 2015年 tongfang. All rights reserved.
//

#import "ViewController.h"
#import <AddressBook/AddressBook.h>
#import "AddContactPersonTool.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    ABAddressBookRef addressBook=ABAddressBookCreate();
   CFArrayRef arratRef=  ABAddressBookCopyArrayOfAllGroups(addressBook);
    NSLog(@"%@",(__bridge_transfer NSArray*)arratRef);
    
    
   [[AddContactPersonTool    shareInstance]toolGetAddrssBookAllPeopleWithCompelet:^(NSMutableArray *personArray) {
       
       for (NSUInteger i=0; i<personArray.count; i++) {
           NSDictionary*dict=personArray[i];
           NSString*name=dict[@"姓名"];
           NSString*first=dict[@"姓"];
           NSString*last=dict[@"名"];
           NSString*s=dict[@"中间名"];
           NSArray*phone=dict[@"电话"];
           UIImage*image=nil;
           if ([dict.allKeys containsObject:@"image"]) {
              image= dict[@"image"];
           }
           NSLog(@"name:%@  first:%@   last:%@   s:%@  phone:%@  image:%@",name,first,last,s,phone,image);
           UIImageView*iamge=[[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
           iamge.image=image;
           [self.view addSubview:iamge];
       }
      
       
      // NSLog(@"%@  %@",personArray,[NSThread currentThread]);
   }];
    NSLog(@"哈哈哈哈");
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
